<?php
/**
 * Created by PhpStorm.
 * User: Lenovo
 * Date: 2018/11/23
 * Time: 15:27
 */
namespace app\index\model;

use think\Model;

/**
 * Class Evalutedesc
 * 评论回复 模型
 */
class Evalutedesc extends Model
{
    protected $autoWriteTimestamp = 'datetime';
    protected $updateTime = false;
    /**
     * @desc  获取指定主评论的评论详情
     * @param $id 主评论id
     * @return $arr 返回指定主评论下边的回复详情
     */
    public static function getEvalutedescById($id)
    {
        $re=self::alias('a')
            ->join('evalute b','a.replyid=b.id','LEFT')
            ->join('user c','a.userid=c.id')
            ->join('user d','a.replyuserid=d.id','LEFT')
            ->where('b.id',$id)
            ->field('a.*,c.name as user,d.name as userreply')
            ->select();
        $arr=[];
        foreach($re as $k){
            $arr[]=$k->toArray();
        }
        return $arr;
    }
}